<?php
import("Weixin.Util.jssdk");
$jssdk = new JSSDK("wx1509e46e90775fe4", "203f4fefd0fc676e1e7c28f28a9ccec5");
$signPackage = $jssdk->GetSignPackage();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="__CSS__/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="__CSS__/jump.css" rel="stylesheet" type="text/css">
    <title>检测选择</title>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                
                <button class="jump btn btn-primary form-control" id="scanQRCode">扫一扫接口 维修 </button>
             
            </div>
        </div>
    </div>
</body>

<script type="text/javascript" src="__JS__/jquery.min.js"></script>
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"> </script>
<script>
  wx.config({
      debug: false,
      appId: '<?php echo $signPackage["appId"];?>', 
      timestamp: <?php echo $signPackage["timestamp"];?>,
      nonceStr: '<?php echo $signPackage["nonceStr"];?>', 
      signature: '<?php echo $signPackage["signature"];?>',
      jsApiList: [
        'checkJsApi',
        'scanQRCode',
      ]
  });

wx.ready(function(){
//1.检查扫一扫接口
     document.querySelector('#scanQRCode').onclick = function () {
        wx.scanQRCode({
          needResult: 1,
          desc: 'scanQRCode desc',
          success: function (res) {  
            var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
            getqrcodes(result);
          }
        });
      };
});

wx.error(function (res) {
  alert(res.errMsg);
});

function getqrcodes(result){
    var my_data=result;
    $.ajax({
       type: "POST",
       url: "http://weixin.yiyikefu.com/index.php?s=/weixin/manage/getqrcodes",
       data: {codes:my_data},
       success: function(response,status,xsr){
            if(response){
              getJson(response);
            }
        },
        error: function(){  
             alert('设备扫描出错啦，请尽快联系管理员~');  
        }
    });
}

//获取返回的json处理结果，并进行操作
function getJson(result){
  var jsonobj=eval('('+result+')');
    var content = jsonobj.content;
    window.location.href= content;
}



</script>
</html>